function post_request(variables, url){
	if (url == null){
		var loc = window.location;
		url = loc.protocol + '//' + loc.host + loc.pathname + loc.search;
	}
	var string = '<form action="' + url + '" method="post">';
	for (var k in variables){
		string += '<input type="hidden" name="'+k+'" value="'+variables[k]+'" />';
	}
	string += '</form>';
	var form = $(string);
	$('body').append(form);
	form.submit();
}

function get_reload()
{
    var loc = window.location;
    window.location.href = loc.protocol + '//' + loc.host + loc.pathname + loc.search;
}

function update_stars(container_id, rating, hidden_field_name){
	if(hidden_field_name != null){
		$("#"+hidden_field_name).val(rating);
	}
	
	var html = "";
	i = 0;
	while (i < 5){
		if(hidden_field_name != null){
			html += (i < rating ? '<span class="noselect" style="color: gold;" onmouseover="update_stars(\''+container_id+'\', '+(i+1)+', \''+hidden_field_name+'\');">★</span>' : '<span class="noselect" onmouseover="update_stars(\''+container_id+'\', '+(i+1)+', \''+hidden_field_name+'\');">☆</span>');
		}else{
			html += (i < rating ? '<span class="noselect" style="color: gold;">★</span>' : '<span class="noselect">☆</span>');
		}
		i += 1;
	}
	$("#"+container_id).html(html);
}

function print_div(div_name) {
	var printContents = document.getElementById(div_name).innerHTML;
	var originalContents = document.body.innerHTML;
	document.body.innerHTML = printContents;
	window.print();
	document.body.innerHTML = originalContents;
}

function alert_message(message, type){
	if(type == null){
		type = "error";
	}
	// types: error, success, info, warning
	$("#alert_container").append('<div class="alerts '+type+'"><span class="alerts_close" onclick="this.parentElement.style.display=\'none\';">×</span>'+message+'</div>');
}